// 版权归 瞄你个汪 所有。使用本代码应遵守相关法律法规和Apache 2.0开源许可要求。
package top.geeke.mapper.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import top.geeke.entity.base.EntityBaseId;
import top.geeke.eunm.SysMenuTypeEnum;
import top.geeke.eunm.SysStatusEnum;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 系统菜单DTO
 * </p>
 * @author 瞄你个汪
 * @since 2024/6/8 20:32
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class MenuOutput extends EntityBaseId implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long pId;

    private SysMenuTypeEnum type;

    @JsonIgnore
    @JsonIgnoreProperties
    private String title;

    @JsonIgnore
    @JsonIgnoreProperties
    private String icon;

    private String name;

    private String path;

    private String component;

    private String redirect;

    @JsonIgnore
    @JsonIgnoreProperties
    private String permission;

    @JsonIgnore
    @JsonIgnoreProperties
    private Boolean isIframe;

    @JsonIgnore
    @JsonIgnoreProperties
    private String outLink;

    @JsonIgnore
    @JsonIgnoreProperties
    private Boolean isHide;

    @JsonIgnore
    @JsonIgnoreProperties
    private Boolean isKeepAlive;

    @JsonIgnore
    @JsonIgnoreProperties
    private Boolean isAffix;

    private SysStatusEnum status;

    private SysMenuMeta meta;

    private List<MenuOutput> children;

    public void renderSysMenuMeta() {
        this.meta = new SysMenuMeta();
        this.meta.title = this.title;
        this.meta.icon = this.icon;
        this.meta.isHide = this.isHide;
        this.meta.isLink = this.outLink;
        this.meta.isAffix = this.isAffix;
        this.meta.isIframe = this.isIframe;
        this.meta.isKeepAlive = this.isKeepAlive;
    }

    @Data
    public static class SysMenuMeta {
        private String title;
        private String icon;
        @JsonProperty("isLink")
        private String isLink;
        @JsonProperty("isHide")
        private boolean isHide;
        @JsonProperty("isAffix")
        private boolean isAffix;
        @JsonProperty("isIframe")
        private boolean isIframe;
        @JsonProperty("isKeepAlive")
        private boolean isKeepAlive;
    }
}
